package com.xbts.system.domain;

import com.baomidou.mybatisplus.annotation.TableField;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;

import javax.swing.tree.TreeNode;
import javax.validation.constraints.NotEmpty;
import javax.validation.constraints.NotNull;

import com.baomidou.mybatisplus.annotation.TableId;
import com.baomidou.mybatisplus.annotation.TableName;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import lombok.Data;
import com.xbts.common.annotation.Excel;
import com.xbts.common.utils.StringUtils;
import com.xbts.common.core.domain.BaseEntity;
import sun.security.x509.GeneralSubtree;

import java.math.BigDecimal;
import java.util.List;
import java.util.Objects;

/**
 * 发票信息对象 sysUserInvoiceInformation
 *
 * @author xbts
 * @date 2023-08-03
 */
@Data
@ApiModel("发票信息对象")
@TableName("sys_user_invoice_information")
public class SysUserInvoiceInformation extends BaseEntity {

    private static final long serialVersionUID=1L;

    /** 用户id */
    @TableId
    private String id;

    /** 用户id */
    private Long userId;

    /** 发票类型*/
    @Excel(name = "发票类型",readConverterExp = "发票类型 value = 1 增值税普通票， value = 2 增值税专用票。 默认value = 1。")
    @ApiModelProperty("发票类型 (发票类型 value = 1 增值税普通票， value = 2 增值税专用票。 默认value = 1。)")
    private Long invoiceType;

    /** 发票抬头 */
    @Excel(name = "发票抬头")
    @ApiModelProperty("发票抬头")
    @NotEmpty(message = "发票抬头不能为空")
    private String invoiceTittle;

    /** 纳税人识别号 */
    @Excel(name = "纳税人识别号")
    @ApiModelProperty("纳税人识别号")
    @NotNull(message = "纳税人识别号不能为空")
    private String taxpayerId;

    /** 收件人姓名 */
    @Excel(name = "收件人姓名")
    @ApiModelProperty("收件人姓名")
    @NotNull(message = "收件人姓名不能为空")
    private String recipientName;

    /** 收件人地址 */
    @Excel(name = "收件人地址")
    @ApiModelProperty("收件人地址")
    @NotEmpty(message = "收件人地址不能为空")
    private String recipientAddress;

    /** 邮箱编码 */
    @Excel(name = "邮箱编码")
    @ApiModelProperty("邮箱编码")
    @NotNull(message = "邮箱编码不能为空")
    private String zipCode;

    /**联系邮箱*/
    @Excel(name = "联系邮箱")
    @ApiModelProperty("联系邮箱")
    @NotEmpty(message = "联系邮箱不能为空")
    private String email;

    /**联系电话*/
    @Excel(name = "联系电话")
    @ApiModelProperty("联系电话")
    @NotNull(message = "联系电话不能为空")
    private String phoneNumber;

    /**是否选择电子发票*/
    @Excel(name = "是否选择电子发票",readConverterExp = "value = 1 是，value = 0 否。")
    @ApiModelProperty("是否选择电子发票 （value = 1 是，value = 0 否。)")
    @NotNull(message = "是否选择电子发票不能为空")
    private boolean whetherElectronicInvoice;


    public<T> QueryWrapper<T> queryWrapper(){
        QueryWrapper<T> queryWrapper=new QueryWrapper<>();
        queryWrapper.like(StringUtils.isNotEmpty(invoiceTittle),"invoice_tittle",invoiceTittle);
        queryWrapper.like(StringUtils.isNotEmpty(recipientName),"recipient_name",recipientName);
        queryWrapper.like(StringUtils.isNotEmpty(recipientAddress),"recipient_address",recipientAddress);
        queryWrapper.like(StringUtils.isNotEmpty(email),"email",email);
        queryWrapper.eq(!Objects.isNull(whetherElectronicInvoice),"whether_electronic_invoice",whetherElectronicInvoice);
        queryWrapper.eq(!Objects.isNull(taxpayerId),"taxpayer_id",taxpayerId);
        queryWrapper.eq(!Objects.isNull(zipCode),"zip_code",zipCode);
        queryWrapper.eq(!Objects.isNull(phoneNumber),"phone_number",phoneNumber);
        return queryWrapper;
    }
}